package network;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2022/4/10
 * \* Time: 14:28
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class UdpDictServer extends UdpEchoServer {
    private HashMap<String ,String> dict = new HashMap<>();
    public UdpDictServer(int port) throws SocketException {
        super(port);
        dict.put("cat","猫猫");
        dict.put("pig","猪猪");
        dict.put("dog","狗狗");
        dict.put("hhh","哈哈");
    }
    @Override
    public String process(String request){
        return dict.getOrDefault(request,"该词无法被翻译");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer server = new UdpDictServer(9000);
        server.start();
    }


}
